package com.wingsoft.work.controller;

import com.wingsoft.common.core.domain.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import com.github.pagehelper.Page;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.wingsoft.common.annotation.Log;
import com.wingsoft.common.core.controller.BaseController;
import com.wingsoft.common.core.domain.AjaxResult;
import com.wingsoft.common.enums.BusinessType;
import com.wingsoft.work.domain.UserTask;
import com.wingsoft.work.dto.UserTaskDto;
import com.wingsoft.work.vo.UserTaskVo;
import com.wingsoft.work.service.impl.UserTaskServiceImpl;
import com.wingsoft.common.utils.poi.ExcelUtil;


@Api(tags = "用户任务接口")
@RestController
@RequestMapping("/work/userTask")
public class UserTaskController extends BaseController
{
    @Autowired
    private UserTaskServiceImpl userTaskService;



    //@PreAuthorize("@ss.hasPermi('work:userTask:list')")
    @PostMapping("/count")
    @ApiOperation("统计数量用户任务")
    public R<Long> count(@RequestBody UserTaskDto userTaskDto)
    {
        Long num = userTaskService.countList(userTaskDto);
        return R.ok(num);
    }



    //@PreAuthorize("@ss.hasPermi('work:userTask:list')")
    @PostMapping("/list")
    @ApiOperation("分页查询用户任务")
    public R<List<UserTaskVo>> list(@RequestBody UserTaskDto userTaskDto)
    {
        Page page = startPage();
        List<UserTaskVo> list = userTaskService.queryList(userTaskDto);
        return getResDataTable(list,page);
    }


    //@PreAuthorize("@ss.hasPermi('work:userTask:list')")
    @PostMapping("/query")
    @ApiOperation("查询用户任务列表")
    public R<List<UserTaskVo>> query(@RequestBody UserTaskDto userTaskDto)
    {
        List<UserTaskVo> list = userTaskService.queryList(userTaskDto);
        return R.ok(list);
    }



    //@PreAuthorize("@ss.hasPermi('work:userTask:export')")
    @Log(title = "导出用户任务", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出用户任务")
    public void export(HttpServletResponse response, UserTaskDto userTaskDto)
    {
        List<UserTaskVo> list = userTaskService.queryList(userTaskDto);
        ExcelUtil<UserTaskVo> util = new ExcelUtil<UserTaskVo>(UserTaskVo.class);
        util.exportExcel(response, list, "用户任务数据");
    }


    //@PreAuthorize("@ss.hasPermi('work:userTask:query')")
    @PostMapping(value = "/get")
    @ApiOperation("获取用户任务详细信息")
    public R<UserTaskVo> getInfo(@RequestBody UserTaskDto userTaskDto)
    {
        return R.ok(userTaskService.getOneById(userTaskDto.getId()));
    }


   /* //@PreAuthorize("@ss.hasPermi('work:userTask:add')")
    @Log(title = "新增用户任务", businessType = BusinessType.INSERT)
    @PostMapping(value = "/add")
    @ApiOperation("新增用户任务")
    public R add(@RequestBody UserTaskDto userTaskDto)
    {
        return R.ok(userTaskService.saveCascade(userTaskDto));
    }



    //@PreAuthorize("@ss.hasPermi('work:userTask:edit')")
    @Log(title = "修改用户任务", businessType = BusinessType.UPDATE)
    @PostMapping(value = "/update")
    @ApiOperation("修改用户任务")
    public R edit(@RequestBody UserTaskDto userTaskDto)
    {
        return R.ok(userTaskService.updateCascade(userTaskDto));
    }

    //@PreAuthorize("@ss.hasPermi('work:userTask:remove')")
    @Log(title = "删除用户任务", businessType = BusinessType.DELETE)
	@PostMapping("/delete/{ids}")
    @ApiOperation("删除用户任务")
    public R remove(@PathVariable Long[] ids)
    {
        userTaskService.removeByIdList(Arrays.asList(ids));
        return R.ok();
    }*/
}
